<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>Eyao订货管理系统</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <link rel="stylesheet" href="__PUBLIC__/layui/css/layui.css"  media="all">
  <link rel="stylesheet" href="__PUBLIC__/font-awesome/css/font-awesome.min.css" media="all" />
  <!-- 注意：如果你直接复制所有代码到本地，上述css路径需要改成你本地的 -->
</head>
<body>
<div style="margin-top: 20px;">
</div>

<div class="layui-btn-group" style="margin-bottom: 20px;margin-left: 20px;">
  <button class="layui-btn">手动添加</button>
  <button class="layui-btn" id="scan">扫码添加</button>
  <button class="layui-btn" id="excel">Excel导入</button>
</div>

<form class="layui-form" id="admin" style="border: 1px solid #eee;width: 700px;padding: 20px;margin-left: 20px;">

  <div class="layui-elem-quote" style="line-height: 8px;">
    <p>手动添加</p>
  </div>

  <div class="layui-form-item">
    <label class="layui-form-label">客户名称</label>
    <div class="layui-input-block" style="max-width:600px;">
      <input name="drug_name" lay-verify="drug_name" autocomplete="off" placeholder="请输入客户名称" class="layui-input" type="text" {notempty name="$data.drug_name"}value="{$data.drug_name}"{/notempty}>
    </div>
  </div>

  <div class="layui-form-item">
    <label class="layui-form-label">客户库存</label>
    <div class="layui-input-block" style="max-width:600px;">
      <input name="drug_number" lay-verify="drug_number" autocomplete="off" placeholder="请输入客户库存" class="layui-input" type="text" {notempty name="$data.drug_number"}value="{$data.drug_number}"{/notempty}>
    </div>
  </div>


  <div class="layui-form-item">
    <label class="layui-form-label">客户单位</label>
    <div class="layui-input-block" style="max-width:600px;">

      <select name="drug_spec_data" lay-verify="">
        <option value="">请选择客户单位</option>
        {volist name="spec_data" id="vo"}
        <option value="{$vo.id}|{$vo.name}" {notempty name="$data.drug_spec_id"}{eq name="$data.drug_spec_id" value="$vo.id"} selected="selected"{/eq}{/notempty}>{$vo.name}</option>
        {/volist}
      </select>

    </div>
  </div>

  <div class="layui-form-item">
    <label class="layui-form-label">客户价格</label>
    <div class="layui-input-block" style="max-width:600px;">
      <input name="drug_price" lay-verify="drug_price" autocomplete="off" placeholder="请输入客户价格" class="layui-input" type="text" {notempty name="$data.drug_price"}value="{$data.drug_price}"{/notempty}>
    </div>
  </div>


  <div class="layui-form-item">
    <label class="layui-form-label">客户厂家</label>
    <div class="layui-input-block" style="max-width:600px;">
      <input name="drug_factory" lay-verify="drug_factory" autocomplete="off" placeholder="请输入客户厂家" class="layui-input" type="text" {notempty name="$data.drug_factory"}value="{$data.drug_factory}"{/notempty}>
    </div>
  </div>


  <div class="layui-form-item">
    <label class="layui-form-label">客户成分</label>
    <div class="layui-input-block" style="max-width:600px;">
      <input name="drug_ingredients" lay-verify="drug_ingredients" autocomplete="off" placeholder="请输入客户成分" class="layui-input" type="text" {notempty name="$data.drug_ingredients"}value="{$data.drug_ingredients}"{/notempty}>
    </div>
  </div>


  <div class="layui-form-item">
    <label class="layui-form-label">功能主治</label>
    <div class="layui-input-block" style="max-width:600px;">
      <input name="drug_functions" lay-verify="drug_functions" autocomplete="off" placeholder="请输入功能主治" class="layui-input" type="text" {notempty name="$data.drug_functions"}value="{$data.drug_functions}"{/notempty}>
    </div>
  </div>


  <div class="layui-form-item">
    <label class="layui-form-label">用法用量</label>
    <div class="layui-input-block" style="max-width:600px;">
      <input name="drug_dosage" lay-verify="drug_dosage" autocomplete="off" placeholder="请输入用法用量" class="layui-input" type="text" {notempty name="$data.drug_dosage"}value="{$data.drug_dosage}"{/notempty}>
    </div>
  </div>


  <div class="layui-form-item">
    <label class="layui-form-label">禁忌症</label>
    <div class="layui-input-block" style="max-width:600px;">
      <input name="drug_contraindication" lay-verify="drug_contraindication" autocomplete="off" placeholder="请输入禁忌症" class="layui-input" type="text" {notempty name="$data.drug_contraindication"}value="{$data.drug_contraindication}"{/notempty}>
    </div>
  </div>


  <div class="layui-form-item">
    <label class="layui-form-label">客户属性</label>
    <div class="layui-input-block" style="max-width:600px;">
      <input name="drug_attribute" lay-verify="drug_attribute" autocomplete="off" placeholder="请输入客户属性" class="layui-input" type="text" {notempty name="$data.drug_attribute"}value="{$data.drug_attribute}"{/notempty}>
    </div>
  </div>


  <div class="layui-form-item">
    <label class="layui-form-label">注意事项</label>
    <div class="layui-input-block" style="max-width:600px;">
      <input name="drug_considerations" lay-verify="drug_considerations" autocomplete="off" placeholder="请输入注意事项" class="layui-input" type="text" {notempty name="$data.drug_considerations"}value="{$data.drug_considerations}"{/notempty}>
    </div>
  </div>


  <div class="layui-form-item">
    <label class="layui-form-label">适应症</label>
    <div class="layui-input-block" style="max-width:600px;">
      <input name="drug_indication" lay-verify="drug_indication" autocomplete="off" placeholder="请输入适应症" class="layui-input" type="text" {notempty name="$data.drug_indication"}value="{$data.drug_indication}"{/notempty}>
    </div>
  </div>


  <div class="layui-form-item">
    <label class="layui-form-label">药理作用</label>
    <div class="layui-input-block" style="max-width:600px;">
      <input name="drug_pharmacological" lay-verify="drug_pharmacological" autocomplete="off" placeholder="请输入药理作用" class="layui-input" type="text" {notempty name="$data.drug_pharmacological"}value="{$data.drug_pharmacological}"{/notempty}>
    </div>
  </div>


  <div class="layui-form-item">
    <label class="layui-form-label">不良反应</label>
    <div class="layui-input-block" style="max-width:600px;">
      <input name="drug_unreaction" lay-verify="drug_unreaction" autocomplete="off" placeholder="请输入不良反应" class="layui-input" type="text" {notempty name="$data.drug_unreaction"}value="{$data.drug_unreaction}"{/notempty}>
    </div>
  </div>


  <div class="layui-form-item">
    <label class="layui-form-label">相互作用</label>
    <div class="layui-input-block" style="max-width:600px;">
      <input name="drug_interaction" lay-verify="drug_interaction" autocomplete="off" placeholder="请输入药物相互作用" class="layui-input" type="text" {notempty name="$data.drug_interaction"}value="{$data.drug_interaction}"{/notempty}>
    </div>
  </div>


  <div class="layui-form-item">
    <label class="layui-form-label">贮藏</label>
    <div class="layui-input-block" style="max-width:600px;">
      <input name="drug_storage" lay-verify="drug_storage" autocomplete="off" placeholder="请输入贮藏" class="layui-input" type="text" {notempty name="$data.drug_storage"}value="{$data.drug_storage}"{/notempty}>
    </div>
  </div>


  <div class="layui-form-item">
    <label class="layui-form-label">有效期</label>
    <div class="layui-input-block" style="max-width:600px;">
      <input name="drug_expiry_date" lay-verify="drug_expiry_date" autocomplete="off" placeholder="请输入有效期" class="layui-input" type="text" id="drug_expiry_date" {notempty name="$data.drug_expiry_date"}value="{$data.drug_expiry_date}"{/notempty}>
    </div>
  </div>


  <div class="layui-form-item">
    <label class="layui-form-label">批准文号</label>
    <div class="layui-input-block" style="max-width:600px;">
      <input name="drug_license_number" lay-verify="drug_license_number" autocomplete="off" placeholder="请输入批准文号" class="layui-input" type="text" {notempty name="$data.drug_license_number"}value="{$data.drug_license_number}"{/notempty}>
    </div>
  </div>


  <div class="layui-form-item">
    <label class="layui-form-label">生产企业</label>
    <div class="layui-input-block" style="max-width:600px;">
      <input name="drug_manufacturing_enterprise" lay-verify="drug_manufacturing_enterprise" autocomplete="off" placeholder="请输入生产企业" class="layui-input" type="text" {notempty name="$data.drug_manufacturing_enterprise"}value="{$data.drug_manufacturing_enterprise}"{/notempty}>
    </div>
  </div>


  <div class="layui-form-item">
    <label class="layui-form-label">拼音码</label>
    <div class="layui-input-block" style="max-width:600px;">
      <input name="drug_pinyin_code" lay-verify="drug_pinyin_code" autocomplete="off" placeholder="请输入拼音码" class="layui-input" type="text" {notempty name="$data.drug_pinyin_code"}value="{$data.drug_pinyin_code}"{/notempty}>
    </div>
  </div>


  <div class="layui-form-item">
    <label class="layui-form-label">别名</label>
    <div class="layui-input-block" style="max-width:600px;">
      <input name="drug_alias" lay-verify="drug_alias" autocomplete="off" placeholder="请输入别名" class="layui-input" type="text" {notempty name="$data.drug_alias"}value="{$data.drug_alias}"{/notempty}>
    </div>
  </div>

  <div class="layui-form-item">
    <label class="layui-form-label">医保类型</label>
    <div class="layui-input-block" style="max-width:600px;">
      <select name="drug_insurance_type" lay-verify="">
        <option value="">请选择医保类型</option>
        <option value="1" {notempty name="$data.drug_insurance_type"}{eq name="$data.drug_insurance_type" value="1"} selected="selected"{/eq}{/notempty}>社会医疗保险</option>
        <option value="2" {notempty name="$data.drug_insurance_type"}{eq name="$data.drug_insurance_type" value="2"} selected="selected"{/eq}{/notempty}>商业医疗保险</option>
      </select>
    </div>
  </div>


  <div class="layui-form-item">
    <label class="layui-form-label">客户剂型</label>
    <div class="layui-input-block" style="max-width:600px;">

      <select name="drug_agent_cate" lay-verify="">
          <option value="">请选择客户剂型</option>
          {volist name="agent_data" id="vo"}
            <option value="{$vo.id}|{$vo.name}" {notempty name="$data.drug_agent_cate_id"}{eq name="$data.drug_agent_cate_id" value="$vo.id"} selected="selected"{/eq}{/notempty}>{$vo.name}</option>
          {/volist}
      </select>

    </div>
  </div>


  <div class="layui-form-item">
    <label class="layui-form-label">客户性质</label>
    <div class="layui-input-block" style="max-width:600px;">

      <select name="drug_nature_cate" lay-verify="">
        <option value="">请选择客户性质</option>
        {volist name="nature_data" id="vo"}
        <option value="{$vo.id}|{$vo.name}" {notempty name="$data.drug_nature_cate_id"}{eq name="$data.drug_nature_cate_id" value="$vo.id"} selected="selected"{/eq}{/notempty}>{$vo.name}</option>
        {/volist}
      </select>

    </div>
  </div>


  <div class="layui-form-item">
    <label class="layui-form-label">目标市场</label>
    <div class="layui-input-block" style="max-width:600px;">

      <select name="drug_market_cate" lay-verify="">
        <option value="">请选择客户目标市场</option>
        {volist name="market_data" id="vo"}
        <option value="{$vo.id}|{$vo.name}" {notempty name="$data.drug_market_cate_id"}{eq name="$data.drug_market_cate_id" value="$vo.id"} selected="selected"{/eq}{/notempty}>{$vo.name}</option>
        {/volist}
      </select>

    </div>
  </div>


  <div class="layui-form-item">
    <label class="layui-form-label">客户用途</label>
    <div class="layui-input-block" style="max-width:600px;">

      <select name="drug_use_cate" lay-verify="">
        <option value="">请选择客户用途</option>
        {volist name="use_data" id="vo"}
        <option value="{$vo.id}|{$vo.name}" {notempty name="$data.drug_use_cate_id"}{eq name="$data.drug_use_cate_id" value="$vo.id"} selected="selected"{/eq}{/notempty}>{$vo.name}</option>
        {/volist}
      </select>

    </div>
  </div>

  <div class="layui-form-item">
    <label class="layui-form-label">所属仓库</label>
    <div class="layui-input-block" style="max-width:600px;">
      <select name="drug_store_house" lay-verify="">
        <option value="">请选择一个仓库</option>
        {volist name="warehouse_data" id="vo"}
        <option value="{$vo.id}|{$vo.warehouse_name}" {notempty name="$data.drug_store_house_id"}{eq name="$data.drug_store_house_id" value="$vo.id"} selected="selected"{/eq}{/notempty}>{$vo.warehouse_name}</option>
        {/volist}
      </select>
    </div>
  </div>

  <div class="layui-form-item">
    <label class="layui-form-label">是否处方药</label>
    <div class="layui-input-block">

      <input type="radio" name="is_otc" value="1" title="非处方药" {notempty name="$data.is_otc"}{eq name="$data.is_otc" value="1"}checked{/eq}{else /}checked{/notempty}>
      <input type="radio" name="is_otc" value="2" title="处方药" {notempty name="$data.is_otc"}{eq name="$data.is_otc" value="2"}checked{/eq}{/notempty}>

    </div>
  </div>

  <div class="layui-form-item">
    <label class="layui-form-label">上架状态</label>
    <div class="layui-input-block">
      <input type="radio" name="status" value="0" title="仓库中" {notempty name="$data.status"}{eq name="$data.status" value="0"}checked{/eq}{else /}checked{/notempty}>
      <input type="radio" name="status" value="1" title="上架" {notempty name="$data.status"}{eq name="$data.status" value="1"}checked{/eq}{/notempty}>
      <input type="radio" name="status" value="2" title="下架" {notempty name="$data.status"}{eq name="$data.status" value="2"}checked{/eq}{/notempty}>
    </div>
  </div>

  <div class="layui-form-item">
    <label class="layui-form-label">是否纳入医保</label>
    <div class="layui-input-block">
      <input type="radio" name="drug_is_insurance" value="1" title="未纳入" {notempty name="$data.drug_is_insurance"}{eq name="$data.drug_is_insurance" value="1"}checked{/eq}{else /}checked{/notempty}>
      <input type="radio" name="drug_is_insurance" value="2" title="已纳入" {notempty name="$data.drug_is_insurance"}{eq name="$data.drug_is_insurance" value="2"}checked{/eq}{/notempty}>
    </div>
  </div>

  <div class="layui-upload" id="upload-thumb">
    <label class="layui-form-label">客户图片</label>
    <button type="button" class="layui-btn" id="drug_thumb"><i class="layui-icon">&#xe67c;</i>上传图片</button>
    <div class="layui-upload-list">
      <label class="layui-form-label"></label>
      <img class="layui-upload-img" id="demo1" width="150" height="150" {notempty name="$data.drug_thumb"}src="{$data.drug_thumb|geturl}"{/notempty}>{notempty name="$data.drug_thumb"}<input type="hidden" name="drug_thumb" value="{$data.drug_thumb}">{/notempty}
      <p id="demoText"></p>
    </div>
  </div>

  <!-- 隐藏元素 start -->

  <input type="hidden" name="drug_store_id" value="{$drug_store_id}" title="所属药企id">

  <input type="hidden" name="id" value="{$data.id}" title="客户id">

  <!-- 隐藏元素   end -->

  <div class="layui-form-item">
    <div class="layui-input-block">
      <button class="layui-btn" lay-submit lay-filter="admin">立即提交</button>
      <button type="reset" class="layui-btn layui-btn-primary">重置</button>
    </div>
  </div>


</form>

<script src="__PUBLIC__/layui/layui.js"></script>
<script src="__PUBLIC__/jquery/jquery.min.js"></script>

<script>
    layui.use('upload', function(){
        var upload = layui.upload;
        //执行实例
        var uploadInst = upload.render({
            elem: '#drug_thumb' //绑定元素
            ,url: "{:url('store/common/upload')}" //上传接口
            ,data:{use:'drug_thumb'}
            ,done: function(res){
                //上传完毕回调
                if(res.code == 2) {
                    $('#demo1').attr('src',res.src);
                    $('#upload-thumb').append('<input type="hidden" name="drug_thumb" value="'+ res.id +'">');
                } else {
                    layer.msg(res.msg);
                }
            }
            ,error: function(){

                //演示失败状态，并实现重传
                var demoText = $('#demoText');

                // 设置上传失败提示信息样式
                demoText.css({ "margin-left" : "50px", "margin-top" : "15px"});

                demoText.html('<span style="color: #FF5722;">上传失败</span> <a class="layui-btn layui-btn-mini demo-reload">重试</a>');

                demoText.find('.demo-reload').on('click', function(){

                    uploadInst.upload();

                });

            }
        });
    });
</script>
<script>

    layui.use(['layer', 'form'], function() {
        var layer = layui.layer,
            $ = layui.jquery,
            form = layui.form;
        $(window).on('load', function() {
            form.on('submit(admin)', function(data) {

                $.ajax({
                    url:"{:url('store/drug/edit')}",
                    data:$('#admin').serialize(),
                    type:'post',
                    async: false,
                    success:function(res) {
                        if(res.code == 1) {
                            layer.alert(res.msg, function(index){
                                location.href = res.url;
                            })
                        } else {
                            layer.msg(res.msg);
                        }
                    }
                })
                return false;
            });
        });
    });

    // 日期控件
    layui.use('laydate', function(){
        var laydate = layui.laydate;

        //执行一个laydate实例
        laydate.render({
            elem: '#drug_expiry_date'  //有效期
        });

    });

    // 扫码添加
    $('#scan').on('click', function(){
        var that = this;
        layer.tips('待开发哦', that); //待开发哦
    });


    // Excel添加
    $('#excel').on('click', function(){
        var that = this;
        layer.tips('待开发哦', that); //待开发哦
    });

</script>

</body>
</html>